package com.azxcrm.project.system.basic.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.azxcrm.common.utils.StringUtils;
import com.azxcrm.project.system.basic.dao.ICustomerProfessionDao;
import com.azxcrm.project.system.basic.domain.CustomerProfession;
import com.azxcrm.project.system.basic.service.ICustomerProfessionService;

/**
 * 职业类型 服务层实现
 * 
 * @author Dustyone
 * @date 2018-08-28
 */
@Service
public class CustomerProfessionServiceImpl implements ICustomerProfessionService 
{
	@Autowired
	private ICustomerProfessionDao customerProfessionDao;
	
	/**
     * 查询职业类型信息
     * 
     * @param professionId 职业类型ID
     * @return 职业类型信息
     */
	 @Override
	public CustomerProfession selectCustomerProfessionById(Integer professionId)
	{
	    return customerProfessionDao.selectCustomerProfessionById(professionId);
	}
	
	/**
     * 查询职业类型列表
     * 
     * @param customerProfession 职业类型信息
     * @return 职业类型集合
     */
	 @Override
	public List<CustomerProfession> selectCustomerProfessionList(CustomerProfession customerProfession)
	{
	    return customerProfessionDao.selectCustomerProfessionList(customerProfession);
	}
	
    /**
     * 新增职业类型
     * 
     * @param customerProfession 职业类型信息
     * @return 结果
     */
	 @Override
	public int insertCustomerProfession(CustomerProfession customerProfession)
	{
	    return customerProfessionDao.insertCustomerProfession(customerProfession);
	}
	
	/**
     * 修改职业类型
     * 
     * @param customerProfession 职业类型信息
     * @return 结果
     */
	 @Override
	public int updateCustomerProfession(CustomerProfession customerProfession)
	{
	    return customerProfessionDao.updateCustomerProfession(customerProfession);
	}
	
	/**
     * 保存职业类型
     * 
     * @param customerProfession 职业类型信息
     * @return 结果
     */
	 @Override
	public int saveCustomerProfession(CustomerProfession customerProfession)
	{
	    Integer professionId = customerProfession.getProfessionId();
		int rows = 0;
		if (StringUtils.isNotNull(professionId))
        {
		    rows = customerProfessionDao.updateCustomerProfession(customerProfession);
		}
		else
        {
		    rows = customerProfessionDao.insertCustomerProfession(customerProfession);
		}
		return rows;
	}
	
	/**
     * 删除职业类型信息
     * 
     * @param professionId 职业类型ID
     * @return 结果
     */
	 @Override
	public int deleteCustomerProfessionById(Integer professionId)
	{
	    return customerProfessionDao.deleteCustomerProfessionById(professionId);
	}
	
	/**
     * 批量删除职业类型对象
     * 
     * @param professionIds 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteCustomerProfession(Integer[] professionIds)
	{
		return customerProfessionDao.batchDeleteCustomerProfession(professionIds);
	}
	
}
